package mysql

import (
	"bluebell/models"
	"errors"
	"go.uber.org/zap"
)

func CreateComment(comment *models.Comment) (err error){
	tx := db.Model(&models.Comment{}).Create(&comment)
	if tx.Error != nil{
		zap.L().Error("insert comment failed", zap.Error(err))
		err = errors.New(ErrorInsertFailed)
		return
	}
	return
}

func GetCommentListById(ids []string) (commentList []*models.Comment, err error){
	tx := db.Model(&models.Comment{}).Where("post_id in ?",ids).Find(commentList)
	if tx.Error != nil{
		return nil,tx.Error
	}
	return
}
